home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48hor1
/
editing.doc
< prev
next >
Wrap
Text File
|
1995-03-31
|
2KB
|
38 lines
Program Editing, by Joseph K. Horn
How can one include pre-written Code objects inside
user-code programs without assembling the entire program?
A very handy way is to use Rick Grevelle's PRG-> and ->PRG routines
(see IO on this disk) with ROLL and ROLLD.
---------------------------Example:--------------------------------
I have a Code object stored in 'JUNK'. I have a program that looks
like this: << A B C + JUNK * >> but I want the program to look
like this: << A B C + Code * >>. Here's how to do it:
1) << A B C + JUNK * >> (this is the original program)
2) PRG-> (decomposes program into its objects + count (8))
3) 4 ROLL (this pulls JUNK down from level 4 to level 1)
4) RCL (this replaces JUNK with its Code contents)
5) 4 ROLLD (this puts the Code into level 4, where JUNK was)
6) ->PRG (this recomposes the program into a single object)
7) See << A B C + Code * >> on the stack!
Steps 3 and 5 are done easily by using the interactive stack. In
fact, this application is the only time I use the interactive
stack.
If more than one replacement is to be made, steps 3 through 5 can
be automated (if you have Donnelly's Tool Library) this way:
->LIST 'JUNK' DUP RCL REPLACE OBJ->. That'll replace every 'JUNK'
with its contents throughout the whole program. Global search and
replace on program objects! Can't do THAT on most handhelds!
Of course, this method can be used to insert "External"s and
anything else your heart desires into programs. You don't ever
have to assemble the whole thing like we used to do! Now you can
write a chunk at a time, verify that each chunk works, and then
tack the chunks together with ->PRG.